<!DOCTYPE html>
<html>

<head>
    <!-- <link rel="shortcut icon" href="" type="image/x-icon"> -->
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta content="width=device-width,initial-scale=1.0" id="vp" name="viewport">
    <meta name="keywords" content="xin留言板">
    <meta name="description" content="xin留言板">
    <meta name="csrf-token" content="{{ csrf_token() }}"> 
    <title>xin会员管理</title>
    <link rel="stylesheet" href="https://cdn.bootcss.com/animate.css/3.5.2/animate.css">
    <link rel="stylesheet" href="{{ URL::asset('css/reset.css') }}">
	<link rel="stylesheet" href="{{ URL::asset('css/base.css') }}">
	<link rel="stylesheet" href="{{ URL::asset('css/public.css') }}">
    <script src="http://apps.bdimg.com/libs/jquery/1.7.1/jquery.min.js"></script>
    <script>hrf = "{{ URL::asset('') }}";console.log(hrf); </script>
</head>

<body>
    <div class="header">
        <div class="header-top">
            <div class="searchnav2">
                <ul class="topnav">
                    <li>
                        <a href="{{ URL::asset('index.php/message') }}">xin留言板</a>
                    </li>
                </ul>
                <!-- <div class="login-info" id="login_no">
                    <a id="regBtn" href="javascript:void(0);" uigs="home_reg_top">注册</a>
                    <a id="loginBtn" href="javascript:void(0);" uigs="home_login_top">登录</a>
                </div> -->
                <div class="login-info" id="login_yes">
                    <a id="home" href="{{ URL::asset('index.php/message') }}" uigs="home_index">留言板</a>
                    <a target="_blank" href="javascript:void(0);" class="yh">
                        <img src="http://wx.qlogo.cn/mmopen/vi_32/J7icgYrfcKJ1pmajEtnr6YEI7LusRkBicJUFYK8UEUGrmCxJDjVPeDLvAnoEu0LS80yhR7Q2ClyFiaa5xj4PTSGMQ/96"
                            width="22" height="22"><span></span></a>
                    <div class="login-pop" id="login_menu" style="display: none;">
                        <i></i>
                        <a href="javascript:void(0);" id="quit">退出</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 登录注册板块/begin -->
    <div id="content-login">
        <div class="outbg"></div>
        <div class="page-outer-wrapper">
            <div class="page-inner-wrapper">
                <div id="popup_login" class="page ">
                    <form id="popup_login_form">
                        <h2>会员登录</h2>
                        <fieldset>
                            <div class="field-tips"></div>
                            <div class="field">
                                <input type="text" name="name" class="input-text" placeholder="手机号 / 邮箱">
                            </div>
                            <div class="field">
                                <input class="login_pwd" type="password" name="password" placeholder="密码">
                            </div>
                            <div class="field">
                                <input class="btn btn-sns" type="button" value="登录">
                            </div>
                            <div class="form-footer">
                                <!--  <span>第三方登录</span>
                	            <ul class="login-third-party">
                	                <li><a class="wechat" href="#">微信登录</a></li>
                	              <li><a class="weibo" target="_top" href="#">微博登录</a></li>
                	            </ul> -->
                                <a href="javascript:void(0);" id="regin">注册帐号</a>
                            </div>
                        </fieldset>
                    </form>
                </div>
                <div id="popup_register" class="page is-hidden">
                    <form id="popup_register_form">
                        <h2>注册会员</h2>
                        <fieldset>
                            <div class="field-tips"></div>
                            <div class="field">
                                <input type="text" name="phone" placeholder="手机号 / 邮箱" autocomplete="off">
                            </div>
                            <div class="field">
                                <input type="password" name="password" placeholder="创建密码" autocomplete="off">
                            </div>
                            <div class="field">
                                <input type="text" name="name" placeholder="昵称" maxlength="14" autocomplete="off">
                            </div>
                            <div class="field">
                                <input class="btn btn-sns" type="button" value="确认注册">
                            </div>
                            <!--  <div class="field center agreement">
        	                    注册即表示你同意遵守 <a href="#" target="_blank">《使用协议》</a>
        	                </div> -->
                            <div class="form-footer">
                                <a href="javascript:void(0);" id="logjoin">登录xin留言板</a>
                            </div>
                        </fieldset>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <!-- 登录注册板块/end -->

    <div class="wrap fix">
        <div class="wrap-left">
            <div class="wrap_table">
                <h2>会员管理</h2>
                <div class="wrap_hred fix">
                    <span>会员昵称</span>
                    <span>会员账号</span>
                    <span>黑名单管理</span>
                </div>
                <ul>
                </ul>
            </div>
        </div>
    </div>
    <script src="{{ URL::asset('js/script.js') }}"></script>
    <script type="text/javascript">
        $(function(){
            $.ajaxSetup({headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')}});
            var loginInfo = JSON.parse(localStorage.getItem('dataArray'));
            
            if(!loginInfo){ 
                location.replace(hrf+'index.php/message');
            }else {
                //获取用户列表
                $.ajax({
                    type: "POST",
                    url: hrf+"index.php/userList",
                    data: {"phone":loginInfo.phone,"accesstoken":loginInfo.accesstoken},
                    dataType: 'json',
                    success: function(data) {
                        if(data.code == '200'){
                            console.log(data);
                            var ssv = data.data.data;
                            console.log(ssv);
                            var leng = ssv.length;//data.data.res 
                            var datajson = data.data.data;
                            console.log(leng);
                            var e = "";
                            if(leng>0){
                                for (i = 0; i< leng;i++) {
                                    var status = datajson[i].status,
                                        statxt = '';
                                        if(status == '2'){
                                            status = 'wrap_out';
                                            statxt = '移出黑名单';

                                        }else {
                                            status = 'wrap_in';
                                            statxt ="加入黑名单";
                                        }
                                    e +='<li class="fix">'+
                                        '<p>'+
                                        decodeURIComponent(datajson[i].nickname)+
                                        '</p>'+
                                        '<p>'+
                                        datajson[i].phone+
                                        '</p>'+
                                        '<p>'+
                                        '<a userid="'
                                        +datajson[i].id
                                        +'" class="'+
                                        status+
                                        '">'+
                                        statxt
                                        +'</a>'+
                                        '<a userid="'
                                        +datajson[i].id
                                        +'" class="'+
                                        'rema'+
                                        '">'+
                                        '删除账号'
                                        +'</a>'+
                                        '</p></li>';
                                };
                                $('.wrap_table ul').html(e);
                        }
                        //分页
                        var f = "";
                        var fpage ='';
                        var fleng = data.data.last_page;
                        for (i = 0; i< fleng;i++) {
                            fpage +='<a class="fpage">'+
                                (i+1) +
                            '</a>';
                        }
                        f ='<div class="page"><span>共'+
                             data.data.last_page+
                             '页,</span>'+
                             fpage
                             '</div>';
                        $('.wrap_table').append(f);
                    }else if(data.code == '201'){
                    	$('.wrap_table ul').html('');
                        alert("请求失败~");
                    }else if(data.code == '202'||data.code == '203'){
                        $('.wrap_table ul').html('');
                        alert("请求信息异常~");
                    }else if(data.code == '205'){
                        $('.wrap_table ul').html('');
                        alert("您未登录哟~");
                    }else if(data.code == '206'){
                        $('.wrap_table ul').html('');
                        alert("你没有权限访问该列表~");
                    }else{
                        $('.wrap_table ul').html('');
                    }
                    },
                    error: function() {}
                })
            $("body").on('click','.wrap_table a',function(){
                var _this = $(this);
                var userid = _this.attr('userid');
                if(_this.is('.wrap_in')){
                    $.ajax({
                        type: "POST",
                        url: hrf+"index.php/blacklistSetting",
                        data: {"phone":loginInfo.phone,"accesstoken":loginInfo.accesstoken,"userid":userid,"status":2},
                        dataType: 'json',
                        success: function(data) {
                            if(data.code == '200'){
                                _this.removeClass('wrap_in').addClass('wrap_out').html('移出黑名单');
                            }else if(data.code == '201'){
                               alert("操作失败");
                            }else if(data.code == '202'||data.code == '203'){
                               alert("请求信息异常");
                            }else if(data.code == '204'){
                               alert("请选择要操作的用户");
                            }else if(data.code == '205'){
                               alert("未登录不能执行该操作哟");
                            }else if(data.code == '206'){
                               alert("您没有权限哟");
                            }
                        }
                    })
                }else if(_this.is('.wrap_out')) {
                    $.ajax({
                        type: "POST",
                        url: hrf+"index.php/blacklistSetting",
                        data: {"phone":loginInfo.phone,"accesstoken":loginInfo.accesstoken,"userid":userid,"status":1},
                        dataType: 'json',
                        success: function(data) {
                            if(data.code == '200'){
                               _this.removeClass('wrap_out').addClass('wrap_in').html('加入黑名单');
                            }else if(data.code == '201'){
                               alert("操作失败");
                            }else if(data.code == '202'||data.code == '203'){
                               alert("请求信息异常");
                            }else if(data.code == '204'){
                               alert("请选择要操作的用户");
                            }else if(data.code == '205'){
                               alert("未登录不能执行该操作哟");
                            }else if(data.code == '206'){
                               alert("您没有权限哟");
                            }
                        }
                    })
                }else if(_this.is('.rema')) {
                    $.ajax({
                        type: "POST",
                        url: hrf+"index.php/blacklistSetting",
                        data: {"phone":loginInfo.phone,"accesstoken":loginInfo.accesstoken,"userid":userid,"status":0},
                        dataType: 'json',
                        success: function(data) {
                            if(data.code == '200'){
                              _this.parents('li').remove();
                            }else if(data.code == '201'){
                               alert("操作失败");
                            }else if(data.code == '202'||data.code == '203'){
                               alert("请求信息异常");
                            }else if(data.code == '204'){
                               alert("请选择要操作的用户");
                            }else if(data.code == '205'){
                               alert("未登录不能执行该操作哟");
                            }else if(data.code == '206'){
                               alert("您没有权限哟");
                            }
                        }
                    })
                }
            })
            
            $("body").on('click','.page a',function(){
                var to_page = $(this).html();
                $.ajax({
                    type: "POST",
                    url: hrf+"index.php/userList"+'?page='+to_page,
                    data: {"phone":loginInfo.phone,"accesstoken":loginInfo.accesstoken},
                    dataType: 'json',
                    success: function(data) {
                        if(data.code == '200'){
                            console.log(data);
                            var ssv = data.data.data;
                            console.log(ssv);
                            var leng = ssv.length;//data.data.res 
                            var datajson = data.data.data;
                            console.log(leng);
                            var e = "";
                            if(leng>0){
                                for (i = 0; i< leng;i++) {
                                    var status = datajson[i].status,
                                        statxt = '';
                                        if(status == '2'){
                                            status = 'wrap_out';
                                            statxt = '移出黑名单';

                                        }else {
                                            status = 'wrap_in';
                                            statxt ="加入黑名单";
                                        }
                                    e +='<li class="fix">'+
                                        '<p>'+
                                        decodeURIComponent(datajson[i].nickname)+
                                        '</p>'+
                                        '<p>'+
                                        datajson[i].phone+
                                        '</p>'+
                                        '<p>'+
                                        '<a userid="'
                                        +datajson[i].id
                                        +'" class="'+
                                        status+
                                        '">'+
                                        statxt
                                        +'</a>'+
                                        '<a userid="'
                                        +datajson[i].id
                                        +'" class="'+
                                        'rema'+
                                        '">'+
                                        '删除账号'
                                        +'</a>'+
                                        '</p></li>';
                                };
                                $('.wrap_table ul').html(e);
                            }
                        }else if(data.code == '201'){
                        	$('.wrap_table ul').html('');
                            alert("请求失败~");
                        }else if(data.code == '202'||data.code == '203'){
                            $('.wrap_table ul').html('');
                            alert("请求信息异常~");
                        }else if(data.code == '205'){
                            $('.wrap_table ul').html('');
                            alert("您未登录哟~");
                        }else if(data.code == '206'){
                            $('.wrap_table ul').html('');
                            alert("你没有权限访问该列表~");
                        }else{
                            $('.wrap_table ul').html('');
                        }
                    }
                })
            })
        }
        });
    </script>
</body>

</html>